package operate;

import book.BookList;

import java.util.Scanner;

/**
 * Created with Intellij IDEA.
 * Description:
 * User: 33013
 * Date: 2023-03-23
 * Time: 23:02
 */
public class ReturnOperate implements Ioperate{
    @Override
    public void work(BookList bookList) {
        System.out.println("请输入要归还的书名");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        for (int i = 0; i < bookList.getBooknumber(); i++) {
            if (bookList.getBookList()[i].getName().equals(name)){
                if (bookList.getBookList()[i].isBorrow() == false){
                    System.out.println("该书没有被借出");
                    return;
                }
                bookList.getBookList()[i].setBorrow(false);
                System.out.println("已归还");
                return;
            }
        }
        System.out.println("查无此书");

    }
}
